/*
Copyright 2010 Bryce Alcock

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.com

 */

package com.ecocrypt.proxy.forwarder.remote;

import com.ecocrypt.proxy.forwarder.gui.RemoteForwarderView;

/**
 *
 * @author bryce
 */
public class ForwarderDestination {
    private String ipAddress;
    private int port;
    private long lastByteTime;
    private String status;

    
    {
        status = "NEW";
    }
    /**
     * @return the ipAddress
     */
    public String getIpAddress() {
	return ipAddress;
    }

    /**
     * @param ipAddress the ipAddress to set
     */
    public void setIpAddress(String ipAddress) {
	this.ipAddress = ipAddress;
    }

    /**
     * @return the port
     */
    public int getPort() {
	return port;
    }

    /**
     * @param port the port to set
     */
    public void setPort(int port) {
	this.port = port;
    }

    /**
     * @return the lastByteTime
     */
    public long getLastByteTime() {
	return lastByteTime;
    }

    /**
     * @param lastByteTime the lastByteTime to set
     */
    public void setLastByteTime(long lastByteTime) {
	this.lastByteTime = lastByteTime;
    }

    @Override
    public int hashCode() {
	int hash = 3;
	hash = 79 * hash + (this.ipAddress != null ? this.ipAddress.hashCode() : 0);
	hash = 79 * hash + this.port;
	return hash;
    }

    @Override
    public boolean equals(Object obj) {
	if (obj == null) {
	    return false;
	}
	if (getClass() != obj.getClass()) {
	    return false;
	}
	final ForwarderDestination other = (ForwarderDestination) obj;
	if ((this.ipAddress == null) ? (other.ipAddress != null) : !this.ipAddress.equals(other.ipAddress)) {
	    return false;
	}
	if (this.port != other.port) {
	    return false;
	}
	return true;
    }

    /**
     * @return the status
     */
    public String getStatus() {
        return status;
    }

    /**
     * @param status the status to set
     */
    public void setStatus(String status) {
        this.status = status;
        //  There may be more efficient ways of doing this.
        RemoteForwarderView.getInstance().updateDestinationTable();
    }
}
